-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add scripts to generate certificate and add it to the macOS Keychain and iOS Keychain #44
base: master
Are you sure you want to change the base?
Conversation
openssl genrsa -aes256 -passout pass:"$password" -out key.pem 2048 | ||
|
||
# Generate the self-signed certificate and private key | ||
openssl req -x509 -new -nodes -passin pass:"$password" -config cert.config -key key.pem -sha256 -extensions v3_ca -days 365 -out root-ca.pem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used "$CERT_FILE"
with -config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Scripts/cert.config
Outdated
C=RU | ||
L=RU | ||
O=Catbird | ||
CN=Catbird |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you probably need to specify the host?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but we do not have website.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to http://localhost
|
||
# Generate the self-signed certificate and private key | ||
openssl req -x509 -new -nodes -passin pass:"$password" -config cert.config -key key.pem -sha256 -extensions v3_ca -days 365 -out root-ca.pem | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Vaport, the key is needed in the Key format .key
openssl rsa -outform der -in key.pem -out cert.key -passin pass:"$password"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
|
||
# Get path to the local keychain and trim whitespaces and quotation marks symbol | ||
LOGIN_KEYCHAIN="$(security login-keychain | sed 's/[[:space:]]*"//g')" | ||
security add-trusted-cert -k $LOGIN_KEYCHAIN root-ca.pem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I need to add to the system Keychain ?
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain root-ca.pem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems, no.
I checked like this import NIOSSL
// ...
try app.http.server.configuration.tlsConfiguration = .makeServerConfiguration(
certificateChain: NIOSSLCertificate.fromPEMFile("cert.pem").map { .certificate($0) },
privateKey: .file("cert.key")
) |
Scripts/generate-self-signed-certificate.sh
— generates self signed certificate (root-ca.pem
) usingScripts/cert.config
config file.Scripts/extract-certificate-from-keychain.sh
— extracts certificate from the local macOS KeychainScripts/add-certificate-to-system-keychain.sh
— adds a certificate to the local macOS KeychainScripts/add-certificate-to-ios-keychain.sh
— adds a certificate to the booted iOS SimulatorCloses #41